package Day07.Demo05;

import java.util.ArrayList;

/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/7 15:22
 */
public class Demo02ArrayListStudent {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student one = new Student("张三",18);
        Student two = new Student("李四",20);
        Student three = new Student("王五",28);
        Student four = new Student("混子",22);
        list.add(one);
        list.add(two);
        list.add(three);
        list.add(four);
        //遍历
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println("学生的姓名是："+stu.getName()+"，年龄是："+stu.getAge());
        }
    }
}
